﻿using BUS;
using DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EC21_EDiamond
{
    public partial class PaySucess : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DonHangDTO dt = new DonHangDTO();
                dt.NgayLap = DateTime.Now.ToShortDateString();
                dt.NgayGiao = DateTime.Now.ToShortDateString();
                dt.TenKH = Session["TenKH"].ToString();
                dt.DiaChi = Session["DiaChi"].ToString();
                dt.DienThoai = Session["DienThoai"].ToString();
                dt.Email = Session["Email"].ToString();
                dt.TinhTrang = 1;
                dt.TrangThai = 1;
                dt.TongTien = Int32.Parse(Session["TongTien"].ToString());
                dt.MaCTVC = 1;
                dt.MaHTG = 1;
                dt.MaKH = Int32.Parse(Session["MaKH"].ToString());
                DonHangBUS.ThemDonHang(dt);
                int maDHCuoi = ChiTietDonHangBUS.DonHangCuoiCung();
                DataTable ds = (DataTable)Session["GioHang"];
                ChiTietDonHangBUS.ThemChiTietDonHang(ds,maDHCuoi.ToString());
            }
        }
    }
}